package com.lzkj.baotouhousingfund.utils;

import android.content.Context;
import android.content.SharedPreferences;

import com.lzkj.baotouhousingfund.app.App;


/**
 * Created by codeest on 16/8/31.
 */

public class SharedPreferenceUtil {


    private static final String USER_ID = "user_id";

    private static final String USER_PHONE = "user_phone";

    private static final String RELOGIN_CLICK = "relogin_status";

    private static final String TOKEN = "token";

    private static final String SP_COOKIE = "cookie";

    private static final String SHAREDPREFERENCES_NAME = "baotou_housing_fund_sp";

    public static SharedPreferences getAppSp() {
        return App.getInstance().getSharedPreferences(SHAREDPREFERENCES_NAME, Context.MODE_PRIVATE);
    }

    public static String getUserPhone() {
        return getAppSp().getString(USER_PHONE, "");
    }

    public static void setUserPhone(String userPhone) {
        getAppSp().edit().putString(USER_PHONE, userPhone).apply();
    }


    public static boolean getReLoginClick() {
        return getAppSp().getBoolean(RELOGIN_CLICK, true);
    }

    public static void setReLoginClick(boolean status) {
        getAppSp().edit().putBoolean(RELOGIN_CLICK, status).apply();
    }


    public static String getUserId() {
        return getAppSp().getString(USER_ID, "");
    }

    public static void setUserId(String id) {
        getAppSp().edit().putString(USER_ID, id).apply();
    }

    public static String getToken() {
        return getAppSp().getString(TOKEN, "");
    }

    public static void setToken(String id) {
        getAppSp().edit().putString(TOKEN, id).apply();
    }

    public static String getCookie() {
        return getAppSp().getString(SP_COOKIE, "");
    }

    public static void setCookie(String cookie) {
        getAppSp().edit().putString(SP_COOKIE, cookie).apply();
    }
}
